<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>员工结算单管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		global.bossPassword = "${fns:getStore().bossPassword}";
		$(document).ready(function() {
			$("#contentTable tbody tr").click(function(){
				$("#contentTable tbody tr").removeClass("select_active");
				$(this).addClass("select_active");
				var url = "${ctx}/employee/storeEmployeeAccountingDetail/list?account_id=" + this.id;
				window.location.href = url;
			});
			$("#searchForm").validate({
				submitHandler: function(form){
					var startValue = $("#startDate").val();
					if (!startValue){
						showTip("开始日期必须填写!");
						return;
					}
					var endValue = $("#endDate").val();
					if (!endValue){
						showTip("结束日期必须填写!");
						return;
					}
					if(startValue && endValue){
						 var start = new Date(startValue.replace(/-/g, "/"));
						 var end = new Date(endValue.replace(/-/g, "/"));
						 if (end < start) {
							showTip("结束日期不能大于开始日期!");
							return;
						}
					}
					bossLoginSubmit('${fns:getStore().bossPassword}', form, '', '');
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
	</script>
</head>
<body>
<div class="icon-buttons">
	<a data-role="button" data-inline="true" data-icon="back" data-iconpos="notext"  href="${ctx}">返回</a>
</div>
	<form:form id="searchForm" modelAttribute="storeEmployeeAccounting" action="${ctx}/employee/storeEmployeeAccounting/" method="post">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<label>开始日期：</label>
		<input type="date" id="startDate" data-inline="true" name="startDate" value="${startDate}"/>
		<label>结束日期：</label>
		<input type="date" id="endDate" data-inline="true" name="endDate" value="${endDate}"/>
		<input id="btnSubmit" type="submit" value="结算单查询" data-inline="true"/>
		<div>
			<input type="button" value="新增结算单" data-inline="true" onclick="bossPasswordPopup('${ctx}/employee/storeEmployeeAccounting/form')">
		</div>
	</form:form>
	<tags:message content="${message}"/>
	<table id="contentTable" data-role="table" class="ui-responsive table-stroke">
		<thead><tr><th>结算日期</th><th>合计薪资</th><th>员工列表</th></tr></thead>
		<tbody>
		<c:forEach items="${page.list}" var="storeEmployeeAccounting">
			<tr id="${storeEmployeeAccounting.id}">
				<td>${storeEmployeeAccounting.accounting_time}</td>
				<td>${storeEmployeeAccounting.total_salary}</td>
				<td>
					<c:forEach items="${storeEmployeeAccounting.detailList}" var="detail">
						${detail.employee.name}<br/>
					</c:forEach>
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>
